import random
import time

def get_radar_data():
    """
    模拟 C1001 雷达 + 环境传感器数据
    逻辑：随机生成 正常/跌倒/离床 三种状态
    """
    seed = random.random()
    
    # 基础环境数据
    temp = round(random.uniform(16.0, 26.0), 1)
    
    data = {
        "timestamp": time.strftime("%H:%M:%S", time.gmtime()),
        "sensor_id": "Radar_LivingRoom_01",
        "heart_rate": random.randint(65, 85),
        "respiration_rate": random.randint(16, 22),
        "temp": temp
    }

    if seed < 0.15: # 15% 概率模拟跌倒 (红色警报)
        data.update({
            "status": "⚠️ 跌倒/剧烈体动", 
            "fall_state": 1, 
            "color": "red",
            "msg": "监测到目标快速下降并静止"
        })
    elif seed < 0.3: # 15% 概率模拟离床 (橙色提示)
        data.update({
            "status": "🛏️ 无人/离床", 
            "fall_state": 0, 
            "heart_rate": 0, 
            "color": "orange",
            "msg": "区域内无活动目标"
        })
    else: # 70% 概率正常 (绿色)
        data.update({
            "status": "🟢 居家活动中", 
            "fall_state": 0, 
            "color": "green",
            "msg": "体征平稳，状态良好"
        })
        
    return data